home *** CD-ROM | disk | FTP | other *** search
/ Complete Linux / Complete Linux.iso / docs / apps / database / postgres / postgre4.z / postgre4 / src / lib / H / utils / catcache.h < prev    next >
Encoding:
C/C++ Source or Header  |  1992-08-27  |  3.0 KB  |  145 lines

  1. /*
  2.  * catcache.h --
  3.  *    Low-level catalog cache definitions.
  4.  *
  5.  * Identification:
  6.  *    $Header: /private/postgres/src/lib/H/utils/RCS/catcache.h,v 1.10 1992/03/02 21:29:12 mer Exp $
  7.  */
  8.  
  9. #ifndef    CatCacheIncluded    /* Include this file only once */
  10. #define CatCacheIncluded    1
  11.  
  12. /* #define    CACHEDEBUG     /* turns DEBUG elogs on */
  13.  
  14. #include "tmp/postgres.h"
  15.     
  16. #include "access/skey.h"
  17. #include "access/htup.h"
  18. #include "utils/rel.h"
  19. #include "tmp/simplelists.h"
  20.  
  21. /*
  22.  *    struct catctup:        tuples in the cache.
  23.  *    struct catcache:    information for managing a cache.
  24.  */
  25.  
  26. typedef struct catctup {
  27.     HeapTuple    ct_tup;        /* A pointer to a tuple        */
  28.     SLNode        ct_node;    /* Doubly linked list node    */
  29.     SLNode        ct_lrunode;    /* ditto, for LRU algorithm    */
  30. } CatCTup;
  31.  
  32. typedef struct catcache {
  33.     ObjectId    relationId;
  34.     ObjectId    indexId;
  35.     char        *cc_relname;    /* relation name for defered open */
  36.     char        *cc_indname;    /* index name for defered open */
  37.     HeapTuple    (*cc_iscanfunc)(); /* index scanfunction */
  38.     TupleDescriptor cc_tupdesc;     /* tuple descriptor from reldesc */
  39.     int        id;        /* XXX could be improved -hirohama */
  40.     short        cc_ntup;    /* # of tuples in this cache    */
  41.     short        cc_maxtup;    /* max # of tuples allowed (LRU)*/
  42.     short        cc_nkeys;
  43.     short        cc_size;
  44.     short        cc_key[4];
  45.     short        cc_klen[4];
  46.     struct skey    cc_skey[4];
  47.     struct catcache *cc_next;
  48.     SLList        cc_lrulist;    /* LRU list, most recent first  */
  49.     SLList        cc_cache[1];    /* Extended over NCCBUCK+1 elmnts*/
  50.                     /* used to be: struct catctup    */
  51. } CatCache;
  52.  
  53. #define    InvalidCatalogCacheId    (-1)
  54.  
  55. extern struct catcache    *Caches;
  56.  
  57. /*
  58.  * InitSysCache --
  59.  */
  60. extern
  61. struct catcache *
  62. InitSysCache ARGS(( char *relname, Name *indname, int nkeys , int key [], HeapTuple (*iScanfuncP)() ));
  63.  
  64. /*
  65.  * ResetSystemCache --
  66.  *    Causes the entire cached system state to be discarded.
  67.  */
  68. extern
  69. void
  70. ResetSystemCache ARGS((
  71.     void
  72. ));
  73.  
  74. /*
  75.  * SearchSysCache --
  76.  */
  77. extern
  78. HeapTuple
  79. SearchSysCache ARGS((
  80.     struct catcache    *cache,
  81.     DATUM        v1,
  82.     DATUM        v2,
  83.     DATUM        v3,
  84.     DATUM        v4
  85. ));
  86.  
  87. /*
  88.  * RelationIdInvalidateCatalogCacheTuple --
  89.  */
  90. extern
  91. void
  92. RelationIdInvalidateCatalogCacheTuple ARGS((
  93.     ObjectId    relationId,
  94.     HeapTuple    tuple,
  95.     void        (*function)()
  96. ));
  97.  
  98. /*
  99.  * CatalogCacheIdInvalidate --
  100.  */
  101. extern
  102. void
  103. CatalogCacheIdInvalidate ARGS((
  104.     int cacheId,
  105.     Index hashIndex,
  106.     ItemPointer pointer
  107. ));
  108.  
  109. /*
  110.  * CatalogCacheComputeTupleHashIndex --
  111.  */
  112. Index CatalogCacheComputeTupleHashIndex ARGS((
  113.     struct catcache *cacheInOutP,
  114.     Relation relation,
  115.     HeapTuple tuple
  116. ));
  117.  
  118. /*
  119.  * CatalogCacheSetId --
  120.  *    XXX This is a temporary function.
  121.  */
  122. extern
  123. void CatalogCacheSetId ARGS((CatCache *cacheInOutP , int id ));
  124.  
  125. void CatalogCacheInitializeCache ARGS((
  126.     struct catcache *cache,
  127.     Relation relation
  128. ));
  129.  
  130. int comphash ARGS((int l , char *v ));
  131.  
  132. Index CatalogCacheComputeHashIndex ARGS((struct catcache *cacheInP ));
  133.  
  134. void CatCacheRemoveCTup ARGS((CatCache *cache , CatCTup *ct ));
  135.  
  136. struct catcache *InitIndexedSysCache ARGS((
  137.     char *relname, 
  138.     char *indname, 
  139.     int nkeys, 
  140.     int key [],
  141.     HeapTuple (*iScanfuncP)()
  142. ));
  143.  
  144. #endif    /* !defined(CatCacheIncluded) */
  145.